﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Colorful.Control.Converters;
using System.Globalization;

namespace Colorful.Test.Unit
{
    [TestClass]
    public class MaxStringLengthConverterTest
    {   
        [TestMethod]
        public void ToLongStringTest()
        {
            var target = new MaxStringLengthConverter();

            string expected = "This is";
            string actual = (string)target.Convert("This is a test", typeof(string), 7, CultureInfo.CurrentCulture);

            Assert.AreEqual<string>(expected, actual);
        }

        [TestMethod]
        public void ToLongStringWithEllipsesTest()
        {
            var target = new MaxStringLengthConverter();
            target.AddEllipsis = true;

            string expected = "This is...";
            string actual = (string)target.Convert("This is a test", typeof(string), 7, CultureInfo.CurrentCulture);

            Assert.AreEqual<string>(expected, actual);
        }

        [TestMethod]
        public void NotToLongStringTest()
        {
            var target = new MaxStringLengthConverter();
            target.AddEllipsis = true;

            string expected = "This is a test";
            string actual = (string)target.Convert("This is a test", typeof(string), 14, CultureInfo.CurrentCulture);

            Assert.AreEqual<string>(expected, actual);
        }

        [TestMethod]
        public void EmptyStringTest()
        {
            var target = new MaxStringLengthConverter();
            target.AddEllipsis = true;

            string expected = "";
            string actual = (string)target.Convert("", typeof(string), 14, CultureInfo.CurrentCulture);

            Assert.AreEqual<string>(expected, actual);
        }
    }
}
